using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class SoldierCamp : ICamp
{
    // 战士等级
    const int MAX_LV = 4;

    private int mLv = 1;

    // 战士的武器(可升级)
    private WeaponType mWeaponType = WeaponType.Gun; // Gun为0

    public SoldierCamp(GameObject gameObject, string name, string icon, SoldierType soldierType, Vector3 position, float trainTime, WeaponType weaponType = WeaponType.Gun, int lv = 1) : base(gameObject, name, icon, soldierType, position, trainTime)
    {
        mLv = lv;
        mWeaponType = weaponType;
        energyCostStrategy = new SoldierEnergyCostStrategy();
        UpdateEnergyCost();
    }

    public override int lv { get { return mLv; } }

    public override WeaponType weaponType { get { return mWeaponType; } }

    public override void Train()
    {
        //添加士兵训练命令(兵营系统中每个兵营对象保存着属性：士兵类型，武器类型，等级，位置) // 训练能量和训练时间？？
        TrainSoldierCommand cmd = new TrainSoldierCommand(mSoldierType, mWeaponType, mPosition, mLv);
        mCommands.Add(cmd);
    }

    protected override void UpdateEnergyCost()
    {
        mEnergyCostCampUpgrade = energyCostStrategy.GetCampUpgradeCost(mSoldierType, mLv);
        mEnergyCostWeaponUpgrade = energyCostStrategy.GetWeaponUpgradeCost(mWeaponType);
        mEnergyCostTrain = energyCostStrategy.GetSoldierTrainCost(mSoldierType, mLv);
    }

    public override void UpgradeCamp()
    {
        mLv++;
        UpdateEnergyCost();
    }

    public override void UpgradeWeapon()
    {
        mWeaponType = mWeaponType + 1;
        UpdateEnergyCost();
    }

    public override int energyCostCampUpgrade
    {
        get
        {
            if (mLv == MAX_LV)
                return -1;
            else
                return mEnergyCostCampUpgrade;
        }
    }

    public override int energyCostWeaponUpgrade
    {
        get
        {
            if (mWeaponType + 1 == WeaponType.MAX)
            {
                return -1;
            } else
            {
                return mEnergyCostWeaponUpgrade;
            }
        }
    }

    public override int energyCostTrain { get { return mEnergyCostTrain; } }
}